<?php
 

/* Check if this is a valid include */
if (!defined('IN_SCRIPT')) {die($hdlang['attempt']);}

$sql = "SELECT name FROM `hd_residences` WHERE ";
 
$sql .= hd_myResid();

$residence = hd_isNumber($_GET['residence']) or $residence=0;
if ($residence) {$sql .= "`id`='$residence' ";}
	 
$result=mysql_query($sql);
$resi=mysql_fetch_object($result);
$res= $resi->name;


$maxresults = hd_isNumber($_GET['limit']) or $maxresults=$hd_settings['max_listings'];
$thispage = hd_isNumber($_GET['page']) or $thispage=1;

$sql_copy=mysql_query("select * from stud_approved where res='JMR'and connected=0 order by room_no asc");  

$result = hd_dbQuery($sql_copy) or hd_error("$hdlang[cant_sql]: $sql</p><p>$hdlang[mysql_said]:<br>".mysql_error()."</p><p>$hdlang[contact_webmsater] $hd_settings[webmaster_mail]");
$all = hd_dbNumRows($result);


$thispages = ceil($all/$maxresults) or $thispages=1;
if ($thispage > $thispages) {$thispage=$thispages;}
$limit_down = (($thispage*$maxresults)-$maxresults);

    $prev_page = ($thispage-1 <= 0) ? 0 : $thispage-1;
    $next_page = ($thispage+1 > $thispages) ? 0 : $thispage+1;

    echo '<form name="HPage"><p align="center">'.sprintf($hdlang['requests_on_pages'],$all,$thispages).' <select name="myHpage">';
    for ($i=1;$i<=$thispages;$i++) {
        echo '<option value="'.$i.'">'.$i.'</option>';
    }
    echo'</select> <input type="button" value="'.$hdlang['go'].'" onClick="Javascript:window.location=\'show_connection.php?'.$query.'\'+document.HPage.myHpage.value"><br />';

    if ($thispages > 7 && $prev_page) {
        echo '
        <a href="show_connection.php?'.$query.$i.'1">&lt;&lt;</a>
        &nbsp;
        <a href="show_connection.php?'.$query.$prev_page.'">&lt;</a>
        &nbsp;
        ';
    }

    for ($i=1; $i<=$thispages; $i++) {
        if ($i <= ($thispage+5) && $i >= ($thispage-5)) {
           if($i == $thispage) {echo ' <b>'.$i.'</b> ';}
           else {echo ' <a href="show_connection.php?'.$query.$i.'">'.$i.'</a> ';}
        }
    }

    if ($thispages > 7 && $next_page) {
        echo '
        &nbsp;
        <a href="show_connection.php?'.$query.$next_page.'">&gt;</a>
        &nbsp;
        <a href="show_connection.php?'.$query.$thispages.'">&gt;&gt;</a>
        ';
    }

    echo '</p></form>';


?>
<form name="form1" action="process_connection.php" method="POST">

<div align="center">
<center>
<table border="0" width="750" cellspacing="1" cellpadding="3" class="white">
<tr>
 
<td class="admin_white">&nbsp;</td>
<td class="admin_white"> <?php echo "NAME:"; ?> </td>
 <td class="admin_white" align="center"> <?php echo "REGNO"; ?> </td>
<td class="admin_white"> <?php echo "DEPT"; ?> </td>
<td class="admin_white" align="center"> <?php echo "MAC"; ?> </td>
<td class="admin_white" align="center"> <?php echo "ROOM NO"; ?> </td>
 
</tr>

<?php
while($request=mysql_fetch_assoc($result))
	{
	 
    if ($i) { $color="admin_white"; $i=0;}
    else {$color="admin_gray";$i=1;}
   

echo <<<EOC
<tr>
<td class="$color" align="center"><input type="checkbox" name="id[]" value="$request[con_no]"></td>
<td class="$color"> $request[uname] </td>
<td class="$color" align="center">$request[regno]</td>
<td class="$color" align="center">$request[dept]</td>
<td class="$color" align="center"> $request[mac]</td>
<td class="$color" align="center"> $request[room_no]</td>

</tr>

EOC;
} // End while
?>
</table>
</center>
</div>

<p>&nbsp; <a href="Javascript:void(0)" onClick="Javascript:hd_changeAll()"><?php echo $hdlang['chg_all']; ?></a></p>

<center><input type="submit" value="Connected" class="button" name="a"></center></p>

</form>
 
 